<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Code Editor External Test</title>
</head>
<body>
<h1>Crunchy External Execution Tests</h1>
<p> External execution of Python programs is currently not working - or, at the very least, not working reliably.  The reason seems to be because Crunchy's new io model redirects stdin and stdout so that GUI program, which handle them in their own way are not capable to interact with Crunchy properly in this environment.  Rather than having a special option like the "old" crunchy, it might be preferable to implement in EditArea a "save and run" function which provides this functionality.
</p>

<h2>Reference for future tests</h2>

<p>Here's an Editor box, try running the code supplied (runs an interpreter):</p>
<pre title="editor external nointernal console">
import code
code.interact()
</pre>
<p>Here's another one, this one requires pygtk (shamelessly lifted from http://www.pygtk.org/pygtk2tutorial/):</p>
<pre title="editor external">
import gtk
class HelloWorld:
    def hello(self, widget, data=None):
        print("Hello World")
    def delete_event(self, widget, event, data=None):
        print("delete event occurred")
        return False
    def destroy(self, widget, data=None):
        gtk.main_quit()
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(10)
        self.button = gtk.Button("Hello World")
        self.button.connect("clicked", self.hello, None)
        self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
        self.window.add(self.button)
        self.button.show()
        self.window.show()
    def main(self):
        gtk.main()
hello = HelloWorld()
hello.main()
</pre>
<p>One of our examples has to be a simple Tkinter application - if only because
Tkinter comes pretty much with all Python distributions and is likely
to be already present on your computer.</p>
<pre title="editor size=(6, 80) external">
from Tkinter import *
root = Tk()
w = Label(root, text="Crunchy!")
w.pack()
root.mainloop()
</pre>
<p>Another example is a basic wxPython application.</p>
<pre title="editor size=(7, 80) external">
import wx
app = wx.PySimpleApp()
frame = wx.Frame(None, -1, "Crunchy Test")
frame.SetBackgroundColour("#33cc33")
frame.SetSize(wx.Size(200, 100))
frame.Show(True)
app.MainLoop()
</pre>

<p><a href="index.html">Back to the test index</a></p>
</body>
</html>
